<?php
$GLOBALS['tpl']->define( array(	'gallery_body'              => 'gallery/gallery_body.html',
                                'gallery_albums_navigation' => 'gallery/gallery_albums_navigation.html',
                                'gallery_photo_item'                => 'gallery/gallery_photo_item.html'
                                ));
$photo_albums=new Tdatasource('photo_albums');
$photos=new Tdatasource('photos');


///////////  Bokovoe menu           ////////////////////////////////////////////
if($photo_albums->select(' `hidden`=0'))do
    {
    $GLOBALS['tpl']->assign(array( 'PHAID'          =>$photo_albums->values['id'],
                                   'ALBUM_RUNAME'   =>$photo_albums->values['ru_name'],
                                   'PHA_MENUCLASS'  =>($photo_albums->values['id']==$_REQUEST['pha'])?'active':''));
    $GLOBALS['tpl']->parse('ALBUMS_NAVIGATION', '.gallery_albums_navigation');
    }
    while($photo_albums->next());
//////////  END Bokovoe menu              //////////////////////////////////////////
$_REQUEST['pha']=$_REQUEST['pha']?$_REQUEST['pha']:2;
//////////  Album content Preview (selected) ///////////////////////////////////
if($_REQUEST['pha'])
{
    $GLOBALS['tpl']->assign(array(   'PHAID'   =>  $_REQUEST['pha'] ));

    if($photos->select(' `album`='.$_REQUEST['pha'].' AND `hidden`=0')) do
    {    
       if(is_file(PARAM_PHOTOS.$_REQUEST['pha'].'/big/'.$photos->values['file']))
       {
           $GLOBALS['tpl']->assign(array(   'PREVIEW_IMG'   =>  (is_file(PARAM_PHOTOS.$_REQUEST['pha'].'/small/'.$photos->values['file']))
                                                                                        ?$_REQUEST['pha'].'/small/'.$photos->values['file']
                                                                                        :'noimage.jpeg',
                                            'FULLSIZE_IMG'  =>  $_REQUEST['pha'].'/big/'.$photos->values['file'],
                                            'PHOTO_TITLE'   =>  $photos->values['title']));
               $GLOBALS['tpl']->parse('PHOTOS_CONTENT', '.gallery_photo_item');
       }
    }while($photos->next());
}
////////// END Album content Preview (selected) ///////////////////////////////////

$GLOBALS['tpl']->parse('CONTENT', 'gallery_body');
?>
